]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Show feedback notifications when the user is busy
authorStéphane Démurget <stephane.demurget@free.fr>
Fri, 2 Nov 2012 17:06:40 +0000 (18:06 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 2 Nov 2012 18:25:26 +0000 (19:25 +0100)
Notifications that are created in response to direct user actions like
"is ready" or "'foo' has been removed from favorites" should always be
displayed even though the user has marked him/herself busy.

https://bugzilla.gnome.org/show_bug.cgi?id=662900

js/ui/appFavorites.js
js/ui/messageTray.js
js/ui/overview.js
js/ui/windowAttentionHandler.js

index 21257bc2a98422d125792a3ef10af75007275c36..2c572d02205946c055a1b64f1369ba4eb453d29d 100644 (file)
@@ -84,9 +84,12 @@ const AppFavorites = new Lang.Class({
 
         let app = Shell.AppSystem.get_default().lookup_app(appId);
 
-        Main.overview.setMessage(_("%s has been added to your favorites.").format(app.get_name()), Lang.bind(this, function () {
-            this._removeFavorite(appId);
-        }));
+        Main.overview.setMessage(_("%s has been added to your favorites.").format(app.get_name()),
+                                 { forFeedback: true,
+                                   undoCallback: Lang.bind(this, function () {
+                                                               this._removeFavorite(appId);
+                                                           })
+                                 });
     },
 
     addFavorite: function(appId) {
@@ -116,9 +119,11 @@ const AppFavorites = new Lang.Class({
             return;
 
         Main.overview.setMessage(_("%s has been removed from your favorites.").format(app.get_name()),
-                                 Lang.bind(this, function () {
-            this._addFavorite(appId, pos);
-        }));
+                                 { forFeedback: true,
+                                   undoCallback: Lang.bind(this, function () {
+                                                               this._addFavorite(appId, pos);
+                                                           })
+                                 });
     }
 });
 Signals.addSignalMethods(AppFavorites.prototype);
index 20358e1d0cb6bdd8de3f46bfb3da1616a5bdba44..2bbdfe8b61108b58dcc12cc95ee9519e626136a5 100644 (file)
@@ -314,6 +314,7 @@ const Notification = new Lang.Class({
         this.resident = false;
         // 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
         this.isTransient = false;
+        this.forFeedback = false;
         this.expanded = false;
         this.focused = false;
         this.acknowledged = false;
@@ -713,6 +714,10 @@ const Notification = new Lang.Class({
         this.isTransient = isTransient;
     },
 
+    setForFeedback: function(forFeedback) {
+        this.forFeedback = forFeedback;
+    },
+
     setUseActionIcons: function(useIcons) {
         this._useActionIcons = useIcons;
     },
@@ -1949,8 +1954,9 @@ const MessageTray = new Lang.Class({
         // Notifications
         let notificationQueue = this._notificationQueue;
         let notificationUrgent = notificationQueue.length > 0 && notificationQueue[0].urgency == Urgency.CRITICAL;
+        let notificationForFeedback = notificationQueue.length > 0 && notificationQueue[0].forFeedback;
         let notificationsLimited = this._busy || this._inFullscreen;
-        let notificationsPending = notificationQueue.length > 0 && (!notificationsLimited || notificationUrgent) && Main.sessionMode.hasNotifications;
+        let notificationsPending = notificationQueue.length > 0 && (!notificationsLimited || notificationUrgent || notificationForFeedback) && Main.sessionMode.hasNotifications;
         let nextNotification = notificationQueue.length > 0 ? notificationQueue[0] : null;
         let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
         let notificationExpanded = this._notification && this._notification.expanded;
index fdfc65c5081766493fc8ba624e45f83bea42b0cc..303cad5a9b14241f02f6e921d4a21742a8334346 100644 (file)
@@ -57,7 +57,14 @@ const ShellInfo = new Lang.Class({
             this._source.destroy();
     },
 
-    setMessage: function(text, undoCallback, undoLabel) {
+    setMessage: function(text, options) {
+        options = Params.parse(options, { undoCallback: null,
+                                          forFeedback: false
+                                        });
+
+        let undoCallback = options.undoCallback;
+        let forFeedback = options.forFeedback;
+
         if (this._source == null) {
             this._source = new MessageTray.SystemNotificationSource();
             this._source.connect('destroy', Lang.bind(this,
@@ -71,6 +78,7 @@ const ShellInfo = new Lang.Class({
         if (this._source.notifications.length == 0) {
             notification = new MessageTray.Notification(this._source, text, null);
             notification.setTransient(true);
+            notification.setForFeedback(forFeedback);
         } else {
             notification = this._source.notifications[0];
             notification.update(text, null, { clear: true });
@@ -78,10 +86,8 @@ const ShellInfo = new Lang.Class({
 
         this._undoCallback = undoCallback;
         if (undoCallback) {
-            notification.addButton('system-undo',
-                                   undoLabel ? undoLabel : _("Undo"));
-            notification.connect('action-invoked',
-                                 Lang.bind(this, this._onUndoClicked));
+            notification.addButton('system-undo', _("Undo"));
+            notification.connect('action-invoked', Lang.bind(this, this._onUndoClicked));
         }
 
         this._source.notify(notification);
@@ -233,11 +239,16 @@ const Overview = new Lang.Class({
         this._viewSelector.removeSearchProvider(provider);
     },
 
-    setMessage: function(text, undoCallback, undoLabel) {
+    //
+    // options:
+    //  - undoCallback (function): the callback to be called if undo support is needed
+    //  - forFeedback (boolean): whether the message is for direct feedback of a user action
+    //
+    setMessage: function(text, options) {
         if (this.isDummy)
             return;
 
-        this._shellInfo.setMessage(text, undoCallback, undoLabel);
+        this._shellInfo.setMessage(text, options);
     },
 
     _onDragBegin: function() {
index 93b39b98b8fe7a8e7ffb0099ae8997ebc69d132f..78e20611e7cbe9c74ab68ff08f670882467c1e41 100644 (file)
@@ -39,6 +39,8 @@ const WindowAttentionHandler = new Lang.Class({
         let [title, banner] = this._getTitleAndBanner(app, window);
 
         let notification = new MessageTray.Notification(source, title, banner);
+        notification.setForFeedback(true);
+
         source.notify(notification);
 
         source.signalIDs.push(window.connect('notify::title', Lang.bind(this, function() {